import dt from '@dt/dt'
import rolesOpt from '@/biz/option/roles.js'
import ruleOpt from '@/biz/option/rule.js'

let _this = null

function roleInfo(info) {
  return rolesOpt.create({
    title: '人员角色',
    key: 'roleIds',
    multiple: true,
    maxTagCount: 2,
    type: 'array',
    col: 18
  })
}

function options(vm) {
  _this = vm
  let arr = [
    [
      {
        title: '人员工号',
        key: 'workNo',
        col: 12,
        text: {}
      },
      {
        title: '人员状态',
        key: 'validate',
        col: 12,
        text: {},
        data: {
          from: (info) => {
            return info.validate == 1 ? '启用' : '禁用'
          }
        }
      }
    ],
    [
      {
        title: '人员姓名',
        key: 'name',
        col: 12,
        text: {}
      },
      {
        title: '当前职级',
        key: 'rankName',
        col: 12,
        text: {}
      }
    ],
    [
      {
        title: '职位状态',
        key: 'status',
        col: 12,
        text: {},
        data: {
          from: (info) => {
            return dt.dictInfo().__value('userStatus', info.status)
          }
        }
      },
      {
        title: '编制类型',
        key: 'jyCompile',
        col: 12,
        text: {},
        data: {
          from: (info) => {
            return info.jyCompile ? '案场编制' : '非案场编制'
          }
        }
      }
    ],
    [
      {
        title: '嘉扬编制',
        key: 'jyCompileStr',
        col: 12,
        text: {}
      },
      {
        title: 'dt编制',
        key: 'dtCompileStr',
        col: 12,
        text: {}
      }
    ],
    [
      {
        title: '手机号',
        key: 'phone',
        col: 12,
        input: {
          maxlength: 11
        },
        rules: [
          {
            required: false,
            message: '请输入手机号',
            trigger: 'blur'
          },
          {
            max: 11,
            message: '最多11个字',
            trigger: 'blur'
          },
          ruleOpt.phone()
        ]
      },
      {
        title: '重置密码',
        key: 'password',
        placeholder: '请输入6-10位数字',
        col: 12,
        button: {
          type: 'primary',
          title: '立即重置',
          click: () => {
            _this.$refs.resetPwd.show()
          }
        }
      }
    ]
  ]
  return arr
}

export default {
  options
}
